{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n",
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from nets.yolo3 import yolo_body\n",
    "from keras.layers import Input\n",
    "from yolo import YOLO\n",
    "from PIL import Image"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:/yolo3-keras-master/logs/ep085-loss12.795-val_loss16.264.h5 model, anchors, and classes loaded.\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0761.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.68'\n",
      "2.0616347999999998\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0781.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.53'\n",
      "0.0700946000000009\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0784.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.31'\n",
      "0.09573330000000624\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0745.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.46'\n",
      "0.10515550000000218\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0759.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.57'\n",
      "0.09365809999999897\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0753.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.54'\n",
      "0.09515460000000076\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0745.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.46'\n",
      "0.10313439999998764\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0656.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.49'\n",
      "0.09715399999998908\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0649.jpg\n",
      "Found 0 boxes for img\n",
      "0.09626629999999636\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0611.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.65'\n",
      "0.1479266999999993\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0616.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.73'\n",
      "0.09499639999998521\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0746.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.71'\n",
      "0.14143960000001243\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0726.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.82'\n",
      "0.11545900000004394\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0751.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.75'\n",
      "0.07103770000003351\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0611.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.65'\n",
      "0.15302350000001752\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0614.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.55'\n",
      "0.08912619999989602\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0614.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.55'\n",
      "0.09481809999999768\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0618.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.56'\n",
      "0.11387380000007852\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0621.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.92'\n",
      "0.08593050000001767\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0622.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.91'\n",
      "0.09482020000007196\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0623.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.84'\n",
      "0.09278469999992467\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0627.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.44'\n",
      "0.1006840000000011\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0629.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.35'\n",
      "0.06898610000007466\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0630.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.60'\n",
      "0.07020469999997658\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0633.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.54'\n",
      "0.07079399999997804\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0636.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.83'\n",
      "0.08683760000008078\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0614.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.55'\n",
      "0.08412780000003295\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0641.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.90'\n",
      "0.06995399999993879\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0544.jpg\n",
      "Found 0 boxes for img\n",
      "0.07991179999999076\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0644.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.70'\n",
      "0.07105000000001382\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0645.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.69'\n",
      "0.10079650000000129\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0646.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.46'\n",
      "0.08354940000003808\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0652.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.52'\n",
      "0.06888960000003408\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0653.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.52'\n",
      "0.06806370000003881\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0654.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.86'\n",
      "0.07051619999992909\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0656.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.49'\n",
      "0.0695971999999756\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0681.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.60'\n",
      "0.09775739999986399\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0649.jpg\n",
      "Found 0 boxes for img\n",
      "0.06956209999998464\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0688.jpg\n",
      "Found 0 boxes for img\n",
      "0.08641020000004573\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0689.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.65'\n",
      "0.18122569999991356\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0390.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.57'\n",
      "0.06894450000004326\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0690.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.71'\n",
      "0.0709486000000652\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0700.jpg\n",
      "Found 0 boxes for img\n",
      "0.0669634999999289\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0701.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.50'\n",
      "0.07092829999987771\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0704.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.44'\n",
      "0.11959430000001703\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0707.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.54'\n",
      "0.08810640000001513\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0710.jpg\n",
      "Found 0 boxes for img\n",
      "0.10158049999995455\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0756.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.80'\n",
      "0.09520929999985128\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0754.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.54'\n",
      "0.06948030000012295\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0758.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.49'\n",
      "0.06985959999997249\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0759.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.57'\n",
      "0.12298729999997704\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0760.jpg\n",
      "Found 0 boxes for img\n",
      "0.06993230000011863\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0765.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.69'\n",
      "0.06894050000005336\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0768.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.87'\n",
      "0.09614400000009482\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0769.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.35'\n",
      "0.0707311999999547\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0781.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.53'\n",
      "0.09940849999998136\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0780.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.86'\n",
      "0.06960400000002664\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0784.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.31'\n",
      "0.06932860000006258\n",
      "Input image filename:D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0788.jpg\n",
      "Found 1 boxes for img\n",
      "b'4 0.71'\n",
      "0.08622270000000753\n"
     ]
    }
   ],
   "source": [
    "yolo = YOLO()\n",
    "\n",
    "while True:\n",
    "    img = input('Input image filename:')\n",
    "    try:\n",
    "        image = Image.open(img)\n",
    "    except:\n",
    "        print('Open Error! Try again!')\n",
    "        continue\n",
    "    else:\n",
    "        r_image = yolo.detect_image(image)\n",
    "        r_image.show()\n",
    "yolo.close_session()\n",
    "\n",
    "#图片路径\n",
    "#D:/yolo3-keras-master/VOCdevkit/VOC2020/JPEGImages/0003.jpg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# yolo = YOLO()\n",
    "# img = input('Input image filename:')\n",
    "# image = Image.open(img)\n",
    "# r_image = yolo.detect_image(image)\n",
    "# r_image.show()\n",
    "# #yolo.close_session()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#第一个类：0001.jpg 面向学生\n",
    "#第二个类：0201.jpg 侧对学生\n",
    "#第三个类：\n",
    "#0703"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
